﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Press.MVC.Data
{    
    public class Post
    {
        public int ID { get; set; }
        public string Title { get; set; }
        public DateTime Timestamp { get; set; }
        public string Summary { get; set; }
        public string Body { get; set; }        
        //public IList<PostComment> PostComments { get; set; }
        public LazyList<PostComment> PostComments { get; set; }
        public int BlogId { get; set; }
        public int PostCategoryID { get; set; }
        public bool AllowComments { get; set; }
        
        public Post() 
        {       
        }

        public Post(string title, int blogId, string summary, string body, int postCategoryId, bool allowComments) 
        {
            this.Title = title;
            this.BlogId = blogId;
            this.Timestamp = DateTime.Now;
            this.Summary = summary;
            this.Body = body;
            this.PostCategoryID = postCategoryId;
            this.AllowComments = allowComments;
        }
        #region object overrides
        public override bool Equals(object obj)
        {
            if (obj is Post)
            {
                Post compareTo = (Post)obj;
                return compareTo.ID == this.ID;
            }
            else
            {
                return base.Equals(obj);
            }
        }

        public override string ToString()
        {
            return this.Title;
        }
        public override int GetHashCode()
        {
            return this.ID.GetHashCode();
        }
        #endregion
    }
}
